#pragma once
#include "common/PSingleton.h"
#include "common/PDefineFunction.h"
#include "GLGlobalInfo.h"
#include "GLGlobalInfoSerialize.h"
#include <stdint.h>
#include <vector>
#include <unordered_map>

class CLogicConfig : public CSingleton<CLogicConfig>
{
	Def_Vec_Set_Get_Val_Func(float, SoulRate)
	Def_Vec_Set_Get_Val_Func(float, QualityRate)

	typedef std::unordered_map<Type_t, GoodsFixInfo*>	MapGoodsFixInfo_t;
public:
	CLogicConfig(void);
	~CLogicConfig(void);
	bool Init();

	const char*				m_LogicIp;
	int16_t					m_LogicPort;

	bool InitGoodsFixInfo();

	bool InitUpLimitBattle();
	bool InitUpLimitLife();
	bool InitDownNeedBattle();
	bool InitUpgradeNeedAll();
	bool InitDefaultBattle();
	bool InitDefaultLife();

	inline const GoodsFixInfo* GetGoodsFix(Type_t type) const;

	Level_t GetBUpLevelLimit(int32_t model) const;
	Level_t GetLUpLevelLimit(int32_t model) const;
	const PropertyCondition* GetBDownPropNeed(int32_t model) const;
	const PropertyCondition* GetAUpgradePropNeed(int32_t level) const;
	Type_t GetDefaultBSkill(int32_t entityType, int32_t model) const;
	Type_t GetDefaultLSkill(int32_t entityType, int32_t model) const;
private:
	MapGoodsFixInfo_t				m_GoodsFixInfo;
	const GoodsFixInfo*				m_DefaultFixInfo;

	CGLGlobalConfig::MapDefaultSkill_t	m_DefaultBSkill;
	CGLGlobalConfig::MapDefaultSkill_t	m_DefaultLSkill;
	CGLGlobalConfig::VecLevel_t			m_BUpLevelLimit;
	CGLGlobalConfig::VecLevel_t			m_LUpLevelLimit;
	CGLGlobalConfig::VecPropCond_t		m_BDownPropNeed;
	CGLGlobalConfig::VecPropCond_t		m_AUpgradePropNeed;
};

const GoodsFixInfo* CLogicConfig::GetGoodsFix(Type_t type) const { 
	MapGoodsFixInfo_t::const_iterator tIter = m_GoodsFixInfo.find(type);
	if (tIter != m_GoodsFixInfo.end())
		return tIter->second;
	return m_DefaultFixInfo;
}